package 笔试真题;

import java.util.Scanner;

public class Shunfen {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int ans =0;
        while (n-->0){
            int m = scanner.nextInt();
            if(dealWith(m)){
                ans ++;
            };
        }
        System.out.println(ans);
    }

    private static boolean dealWith(int m) {
        String s = String.valueOf(m);
        int len = s.length();
        if(s.charAt(len-1)!=s.charAt(len-2)){
            return false;
        }
        char temp = s.charAt(len-1);
        for (int i = len-2; i >=0; i--) {
            if(s.charAt(i)==temp) continue;
            if(s.charAt(i)>temp) return false;
            temp = s.charAt(i);
        }
        return true;
    }
}
